<template>
  <div>
    <p>
      <a-radio-group v-model="activeKey" name="radioGroup" @change="onChange">
        <a-radio :value="1">
          本月
        </a-radio>
        <a-radio :value="2">
          上月
        </a-radio>
      </a-radio-group>
    </p>
    <s-table
      bordered
      ref="table"
      :row-key="(record,index) => index"
      :columns="performanceColumns"
      :data="performanceData"
    >
      <template slot="performance" slot-scope="text,record">
        <a-tag color="red" v-if="activeKey == 1">
          {{record.by_yj}}
        </a-tag>
        <a-tag color="red" v-if="activeKey == 2">
          {{record.sy_yj}}
        </a-tag>
      </template>
    </s-table>
  </div>
</template>

<script>
import { STable } from '@/components'
import col from '@/columns/group'
import { getPerformance } from '@/api/group'
export default {
  props: {
    uid: {
      type: String,
      default: ''
    }
  },
  components: {
    STable
  },
  name: 'Performance',
  data () {
    return {
      performanceColumns: col.performance,
      performanceData: parameters => {
        return getPerformance(Object.assign(parameters, this.queryParam)).then(res => {
          return res.result
        })
      },
      queryParam: {},
      activeKey: 1,
      activeId: ''
    }
  },
  created () {
    this.activeId = this.uid
    this.queryParam['uid'] = this.activeId
    this.queryParam['type'] = this.activeKey
  },
  methods: {
    onChange (e) {
      this.queryParam['type'] = e.target.value
      this.$refs.table.refresh(true)
    }
  }
}
</script>

<style scoped>

</style>
